package com.labofjet.blogv3.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

import com.labofjet.blogv3.dao.ICategoryDao;
import com.labofjet.blogv3.model.Category;

@Service
public class CategoryService {
	@Autowired
	private ICategoryDao dao;

	@Cacheable(value = "category", key = "'all'")
	public List<Category> findAll() {
		return dao.findAll();
	}

	@Caching(evict = { @CacheEvict(value = "category", allEntries = true) })
	public void save(Category c) {
		dao.save(c);
	}

	@Caching(evict = { @CacheEvict(value = "category", allEntries = true) })
	public void delete(long id) {
		dao.delete(id);
	}
}
